/**
 * Created by Freeman on 2016/7/6.
 */
"use strict";

import {WRITER_UPDATE_ARTICLE,REQUEST_PUBLISH_ARTICLE,PUBLISH_ARTICLE_SUCCESS,PUBLISH_ARTICLE_FAILURE} from '../types'

const state = {
    isPublishing:false,
    item:{
        id:'',
        title:'无标题文章',
        content:'# 1231231'
    }
}

const mutations = {
    [REQUEST_PUBLISH_ARTICLE](state){
        state.isPublishing = true
    },
    [WRITER_UPDATE_ARTICLE](state,action){
        state.item = {...state.item,...action.article}
    },
    [PUBLISH_ARTICLE_SUCCESS](state){
        state.item = {
            id:'',
            title:'无标题文章',
            content:'# 1231231'
        }
        state.isPublishing = false
    },
    [PUBLISH_ARTICLE_FAILURE](state){
        state.isPublishing = false
    }
}

export default {
    state,
    mutations
}